radio-menu-item: Allow arguments to be NULL
authorMatthias Clasen <mclasen@redhat.com>
Sun, 22 Mar 2015 05:54:08 +0000 (01:54 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 22 Mar 2015 06:10:38 +0000 (02:10 -0400)
Some arguments, like the group and the label of a RadioMenuItem, can be
NULL: the RadioMenuItem has all the code to deal with them. The argument
validation is too strict, though, for instance doing:

  return_if_fail (IS_RADIO_MENU_ITEM (foo))

  if (foo != NULL)
    set_foo (foo)

Which is obviously incorrect.

This commit also modifies the annotations of the API, to ensure that
language bindings do the right thing.

https://bugzilla.gnome.org/show_bug.cgi?id=671362

gtk/gtkradiomenuitem.c

index ee49423325dc8efd4b153aaef5978186b1dac77d..da371204311c863c284678d337bbf698a565687a 100644 (file)
@@ -284,7 +284,7 @@ gtk_radio_menu_item_new_with_mnemonic (GSList *group,
 
 /**
  * gtk_radio_menu_item_new_from_widget: (constructor)
- * @group: An existing #GtkRadioMenuItem
+ * @group: (allow-none): An existing #GtkRadioMenuItem
  *
  * Creates a new #GtkRadioMenuItem adding it to the same group as @group.
  *
@@ -297,7 +297,7 @@ gtk_radio_menu_item_new_from_widget (GtkRadioMenuItem *group)
 {
   GSList *list = NULL;
   
-  g_return_val_if_fail (GTK_IS_RADIO_MENU_ITEM (group), NULL);
+  g_return_val_if_fail (group == NULL || GTK_IS_RADIO_MENU_ITEM (group), NULL);
 
   if (group)
     list = gtk_radio_menu_item_get_group (group);
@@ -307,8 +307,8 @@ gtk_radio_menu_item_new_from_widget (GtkRadioMenuItem *group)
 
 /**
  * gtk_radio_menu_item_new_with_mnemonic_from_widget: (constructor)
- * @group: An existing #GtkRadioMenuItem
- * @label: the text of the button, with an underscore in front of the
+ * @group: (allow-none): An existing #GtkRadioMenuItem
+ * @label: (allow-none): the text of the button, with an underscore in front of the
  *         mnemonic character
  *
  * Creates a new GtkRadioMenuItem containing a label. The label will be
@@ -327,7 +327,7 @@ gtk_radio_menu_item_new_with_mnemonic_from_widget (GtkRadioMenuItem *group,
 {
   GSList *list = NULL;
 
-  g_return_val_if_fail (GTK_IS_RADIO_MENU_ITEM (group), NULL);
+  g_return_val_if_fail (group == NULL || GTK_IS_RADIO_MENU_ITEM (group), NULL);
 
   if (group)
     list = gtk_radio_menu_item_get_group (group);
@@ -337,8 +337,8 @@ gtk_radio_menu_item_new_with_mnemonic_from_widget (GtkRadioMenuItem *group,
 
 /**
  * gtk_radio_menu_item_new_with_label_from_widget: (constructor)
- * @group: an existing #GtkRadioMenuItem
- * @label: the text for the label
+ * @group: (allow-none): an existing #GtkRadioMenuItem
+ * @label: (allow-none): the text for the label
  *
  * Creates a new GtkRadioMenuItem whose child is a simple GtkLabel.
  * The new #GtkRadioMenuItem is added to the same group as @group.
@@ -353,7 +353,7 @@ gtk_radio_menu_item_new_with_label_from_widget (GtkRadioMenuItem *group,
 {
   GSList *list = NULL;
 
-  g_return_val_if_fail (GTK_IS_RADIO_MENU_ITEM (group), NULL);
+  g_return_val_if_fail (group == NULL || GTK_IS_RADIO_MENU_ITEM (group), NULL);
 
   if (group)
     list = gtk_radio_menu_item_get_group (group);